package lu.uni.adtool.ui;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;

/**
 * Panel that contains details about domain canvas.
 * 
 * @author Piot Kordy
 */
public class DetailsView extends JPanel
{
  static final long serialVersionUID = 16648641466469654L;
  private JLabel text;
  private DomainCanvas canvas;
  /**
   * Constructs a new instance.
   */
  public DetailsView()
  {
    super(new BorderLayout());
    canvas = null;
    text = new JLabel("No attribute domain chosen.")
    {
      public Dimension getPreferredSize()
      {
        return new Dimension(400, 300);
      }

      public Dimension getMinimumSize()
      {
        return new Dimension(400, 300);
      }

      public Dimension getMaximumSize()
      {
        return new Dimension(400, 300);
      }
    };
    text.setVerticalAlignment(SwingConstants.TOP);
    text.setFont(new Font("Sans", Font.TRUETYPE_FONT, 13));
    text.setHorizontalAlignment(SwingConstants.LEFT);

    JScrollPane descPane = new JScrollPane(text);
    descPane.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createEmptyBorder(10, 10, 10, 10),
        BorderFactory.createTitledBorder("Attribute domain details:")));
    descPane.setAutoscrolls(true);
    add(descPane);
  }
  /**
   * Assign canvas to this view.
   * 
   * @param canvas canvas.
   */
  public void assignCanvas(DomainCanvas canvas)
  {
    this.canvas = canvas;
    if(canvas == null){
      text.setText("No attribute domain chosen.");
    }
    else{
      text.setText(canvas.getDomain().getDescription());
    }
  }
}
